import request from '@/utils/request'
// -------- 项目类型 --------

let BASE_ADDRESS = 'work/projectType'

//  分页查询
export const getProjectTypelistApi = (params)=> {
    return request({
        url: `${BASE_ADDRESS}/list`,
        method: "get",
        params
    })
}

//  只显示状态是开启的项目 分页查询
export const getFindProjectTypelistApi = (params)=> {
    return request({
        url: `${BASE_ADDRESS}/findProjectTypeList`,
        method: "get",
        params
    })
}

// 添加项目类别 /work/projectType/add
export const addProjectTypeApi = (data) =>{
    return request({
        url: `${BASE_ADDRESS}/add`,
        method: "post",
        data
    })
}

//编辑项目类别 /work/projectType/edit
export const editProjectTypeApi = (data) =>{
    return request({
        url: `${BASE_ADDRESS}/edit`,
        method: "put",
        data
    })
}

//绑定/解绑 项目材料的接口
// /work/projectMaterial/unbind?typeId=11&materialId=22  解绑
// /work/projectMaterial/bind?typeId=11&materialId=22  绑定
export const bindOrUnbindProjectMaterialApi = (data) =>{
    // checked为true就是绑定，false是解绑
    if(data.checked){
        return request({
            url: `/work/projectMaterial/bind?typeId=${data.typeId}&materialId=${data.materialId}`,
            method: "post",
        })
    }else{
        return request({
            url: `/work/projectMaterial/unbind?typeId=${data.typeId}&materialId=${data.materialId}`,
            method: "delete",
        })
    }
}

// 查询项目类型绑定了哪些材料  /work/projectMaterial/checked
export const getProjectMaterialCheckedApi = (typeId) =>{
    return request({
        url: `/work/projectMaterial/checked?typeId=${typeId}`,
        method: "get",
    })
}

// 根据id查询
export const getProjectTypeGetInfoApi = (params) =>{
    return request({
        url: `/work/projectType/getInfo`,
        method: "get",
        params
    })
}

// 查询项目问答 /work/projectQa/list
export const getProjectQaListApi = (params) =>{
    return request({
        url: `/work/projectQa/list`,
        method: "get",
        params
    })
}

// 保存项目问答 /work/projectQa/addListCover
export const addListCoverProjectQaApi = (data) =>{
    return request({
        url: `/work/projectQa/addListCover`,
        method: "post",
        data
    })
}